home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 42
/
Amiga Format AFCD42 (Issue 126, Aug 1999).iso
/
-serious-
/
programming
/
other
/
jikes
/
src
/
class.h
< prev
next >
Wrap
C/C++ Source or Header
|
1999-05-14
|
31KB
|
1,039 lines
// $Id: class.h,v 1.5 1999/02/01 17:43:05 shields Exp $
//
// This software is subject to the terms of the IBM Jikes Compiler
// License Agreement available at the following URL:
// http://www.ibm.com/research/jikes.
// Copyright (C) 1996, 1998, International Business Machines Corporation
// and others. All Rights Reserved.
// You must accept the terms of that agreement to use this software.
//
#ifndef class_INCLUDED
#define class_INCLUDED
#include "config.h"
#include <stdio.h>
#include "semantic.h"
#include "access.h"
#include "unicode.h"
#include "tuple.h"
class cp_info
{
public:
u1 tag;
cp_info(u1 _tag) : tag(_tag) {}
virtual ~cp_info() {}
virtual void put(OutputBuffer &output_buffer)
{
assert("trying to put unsupported attribute kind" == NULL);
}
#ifdef TEST
virtual void print(Tuple<cp_info *>& constant_pool) {
cout << (int) tag;
}
virtual void describe(Tuple<cp_info *>& constant_pool) {
cout << (int) tag;
}
#endif
};
class CONSTANT_Class_info : public cp_info
{
public:
/* u1 tag; */
u2 name_index;
CONSTANT_Class_info(u1 _tag) : cp_info(_tag) {}
virtual ~CONSTANT_Class_info() {}
virtual void put(OutputBuffer &output_buffer)
{
output_buffer.PutB1(tag);
output_buffer.PutB2(name_index);
}
#ifdef TEST
virtual void print(Tuple<cp_info *>& constant_pool) {
cout << "CONSTANT_Class_info: name_index " << name_index << "\n";
}
virtual void describe(Tuple<cp_info *>& constant_pool) {
cout << "Class:"; constant_pool[name_index]->describe(constant_pool);
}
#endif
};
class CONSTANT_Double_info : public cp_info
{
public:
/* u1 tag; */
u4 high_bytes;
u4 low_bytes;
CONSTANT_Double_info(u1 _tag) : cp_info(_tag) {}
virtual ~CONSTANT_Double_info() {}
virtual void put(OutputBuffer &output_buffer)
{
output_buffer.PutB1(tag);
output_buffer.PutB4(high_bytes);
output_buffer.PutB4(low_bytes);
}
#ifdef TEST
virtual void print(Tuple<cp_info *>& constant_pool) {
cout << "CONSTANT_Float_info: bytes \n";
}
virtual void describe(Tuple<cp_info *>& constant_pool) {
cout << "D:";
// constant_pool[string_index]->describe(constant_pool);
}
#endif
};
class CONSTANT_Fieldref_info : public cp_info
{
public:
/* u1 tag; */
u2 class_index;
u2 name_and_type_index;
CONSTANT_Fieldref_info(u1 _tag) : cp_info(_tag) {}
virtual ~CONSTANT_Fieldref_info() {}
virtual void put(OutputBuffer &output_buffer)
{
output_buffer.PutB1(tag);
output_buffer.PutB2(class_index);
output_buffer.PutB2(name_and_type_index);
}
#ifdef TEST
virtual void print(Tuple<cp_info *>& constant_pool) {
cout << "CONSTANT_Fieldref_info: class_index: " << class_index
<< ", name_and_type_index: " << name_and_type_index << "\n";
}
virtual void describe(Tuple<cp_info *>& constant_pool) {
constant_pool[class_index]->describe(constant_pool); cout << ".";
constant_pool[name_and_type_index]->describe(constant_pool);
}
#endif
};
class CONSTANT_Float_info : public cp_info
{
public:
/* u1 tag; */
u4 bytes;
CONSTANT_Float_info(u1 _tag) : cp_info(_tag) {}
virtual ~CONSTANT_Float_info() {}
virtual void put(OutputBuffer &output_buffer)
{
output_buffer.PutB1(tag);
output_buffer.PutB4(bytes);
}
#ifdef TEST
virtual void print(Tuple<cp_info *>& constant_pool) {
cout << "CONSTANT_Float_info: bytes " << (float) bytes << "\n"; //DSDouble
}
virtual void describe(Tuple<cp_info *>& constant_pool) {
cout << "F:";
// constant_pool[string_index]->describe(constant_pool);
}
#endif
};
class CONSTANT_Integer_info : public cp_info
{
public:
/* u1 tag; */
u4 bytes;
CONSTANT_Integer_info(u1 _tag) : cp_info(_tag) {}
virtual ~CONSTANT_Integer_info() {}
virtual void put(OutputBuffer &output_buffer)
{
output_buffer.PutB1(tag);
output_buffer.PutB4(bytes);
}
#ifdef TEST
virtual void print(Tuple<cp_info *>& constant_pool) {
int val;
val = ((bytes>>24)&0xff)<<24 | ((bytes>>16)&0xff)<<16
| ((bytes>>8)&0xff)<<8 | (bytes&0xff);
// cout << "CONSTANT_Integer_info: bytes " << value << "\n";
cout << "CONSTANT_Integer_info: bytes " << val << "\n";
}
virtual void describe(Tuple<cp_info *>& constant_pool) {
cout << "I:";
// constant_pool[string_index]->describe(constant_pool);
}
#endif
};
class CONSTANT_InterfaceMethodref_info : public cp_info
{
public:
/* u1 tag; */
u2 class_index;
u2 name_and_type_index;
CONSTANT_InterfaceMethodref_info(u1 _tag) : cp_info(_tag) {}
virtual ~CONSTANT_InterfaceMethodref_info() {}
virtual void put(OutputBuffer &output_buffer)
{
output_buffer.PutB1(tag);
output_buffer.PutB2(class_index);
output_buffer.PutB2(name_and_type_index);
}
#ifdef TEST
virtual void print(Tuple<cp_info *>& constant_pool) {
cout << "CONSTANT_InterfaceMethodref_info: class_index: " << class_index
<< ", name_and_type_index: " << name_and_type_index << "\n";
}
virtual void describe(Tuple<cp_info *>& constant_pool) {
constant_pool[class_index]->describe(constant_pool); cout << ".";
constant_pool[name_and_type_index]->describe(constant_pool);
}
#endif
};
class CONSTANT_Long_info : public cp_info
{
public:
/* u1 tag; */
u4 high_bytes;
u4 low_bytes;
CONSTANT_Long_info(u1 _tag) : cp_info(_tag) {}
virtual ~CONSTANT_Long_info() {}
virtual void put(OutputBuffer &output_buffer)
{
output_buffer.PutB1(tag);
output_buffer.PutB4(high_bytes);
output_buffer.PutB4(low_bytes);
}
#ifdef TEST
virtual void print(Tuple<cp_info *>& constant_pool) {
cout << "CONSTANT_Long_info: bytes \n";
}
virtual void describe(Tuple<cp_info *>& constant_pool) {
cout << "L:";
// constant_pool[string_index]->describe(constant_pool);
}
#endif
};
class CONSTANT_Methodref_info : public cp_info
{
public:
/* u1 tag; */
u2 class_index;
u2 name_and_type_index;
CONSTANT_Methodref_info(u1 _tag) : cp_info(_tag) {}
virtual ~CONSTANT_Methodref_info() {}
virtual void put(OutputBuffer &output_buffer)
{
output_buffer.PutB1(tag);
output_buffer.PutB2(class_index);
output_buffer.PutB2(name_and_type_index);
}
#ifdef TEST
virtual void print(Tuple<cp_info *>& constant_pool) {
cout << "CONSTANT_Methodref_info: class_index: " << class_index
<< ", name_and_type_index: " << name_and_type_index << "\n";
}
virtual void describe(Tuple<cp_info *>& constant_pool) {
constant_pool[class_index]->describe(constant_pool); cout << ".";
constant_pool[name_and_type_index]->describe(constant_pool);
}
#endif
};
class CONSTANT_NameAndType_info : public cp_info
{
public:
/* u1 tag; */
u2 name_index;
u2 descriptor_index;
CONSTANT_NameAndType_info(u1 _tag) : cp_info(_tag) {}
virtual ~CONSTANT_NameAndType_info() {}
virtual void put(OutputBuffer &output_buffer)
{
output_buffer.PutB1(tag);
output_buffer.PutB2(name_index);
output_buffer.PutB2(descriptor_index);
}
#ifdef TEST
virtual void print(Tuple<cp_info *>& constant_pool) {
cout << "CONSTANT_NameAndType_info: name_index: " << name_index
<< ", descriptor_index: " << descriptor_index << "\n";
}
virtual void describe(Tuple<cp_info *>& constant_pool) {
constant_pool[name_index]->describe(constant_pool);
cout << " ";
constant_pool[descriptor_index]->describe(constant_pool);
}
#endif
};
class CONSTANT_String_info : public cp_info
{
public:
/* u1 tag; */
u2 string_index;
CONSTANT_String_info(u1 _tag) : cp_info(_tag) {}
virtual ~CONSTANT_String_info() {}
virtual void put(OutputBuffer &output_buffer)
{
output_buffer.PutB1(tag);
output_